import React,{Component} from 'react';
import axios from 'axios'

export default class Login extends Component{
    state={
        user:'',
        pass:'',
        bannerList:[1,2,3]
    }
    componentDidMount(){
        axios.get('http://1.116.129.85:8080/home/banner').then(res =>{
            let bannerList = res.data
            this.setState({
                bannerList
            })
        })
    }
    passChange = (e) => {
        const {pass} = this.state;
        let pass1= e.target.value;
        this.setState({pass:pass1})
    }
    submit = () => {
        axios.post('http://1.116.129.85:8080/login',{
            user:this.userInput.value,
            pass:this.state.pass
        }).then(res =>{

        })
    }
    render() {
        const{bannerList} = this.state;
        return(
            <div>
                <div>login
                    <ul>
                        {
                            bannerList.map((item,index) => (
                                <li>
                                    <img src={item.imgUrl} key={index} alt=""/>
                                </li>
                            ))
                        }

                    </ul>
                </div>
                <div>
                    <div>用户名：</div>
                    <input type="text" ref={val => this.userInput = val}/>
                    <div>密码：</div>
                    <input type="password" value={this.state.pass} onChange={this.passChange}/>
                    <div onClick={this.submit}>登陆</div>
                </div>
            </div>
        )
    }
}